﻿<Page x:Class="App45.MainPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:ViewModels="using:App45.ViewModels"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:local="using:App45"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      mc:Ignorable="d">

    <Page.DataContext>
        <ViewModels:MainPageViewModel />
    </Page.DataContext>

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Grid HorizontalAlignment="Center" VerticalAlignment="Center">
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition />
                <ColumnDefinition />
                <ColumnDefinition />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="200" />
                <RowDefinition Height="200" />
            </Grid.RowDefinitions>
            <Grid.Resources>
                <Style TargetType="Image">
                    <Setter Property="Stretch" Value="UniformToFill" />
                    <Setter Property="Width" Value="275" />
                </Style>
                <Style TargetType="TextBlock">
                    <Setter Property="TextTrimming" Value="CharacterEllipsis" />
                    <Setter Property="TextWrapping" Value="Wrap" />
                    <Setter Property="Width" Value="275" />
                </Style>
            </Grid.Resources>
            <Image x:Name="image"
                   Grid.Row="0"
                   Grid.Column="0"
                   Source="ms-appx:///Images/StarTrek.jpg" />
            <Button Grid.Row="0"
                    Grid.Column="1"
                    Command="{Binding ToTextCommand}"
                    CommandParameter="{Binding ElementName=image}">
                To String
            </Button>
            <TextBlock Grid.Row="0"
                       Grid.Column="2"
                       Text="{Binding Text}" />
            <Button Grid.Row="1"
                    Grid.Column="1"
                    Command="{Binding FromTextCommand}"
                    Content="To Image" />
            <TextBlock Grid.Row="1"
                       Grid.Column="2"
                       VerticalAlignment="Center"
                       TextAlignment="Center">
                Image
            </TextBlock>
            <Image Grid.Row="1"
                   Grid.Column="2"
                   DataContext="{Binding Image}"
                   Source="{Binding}" />
        </Grid>
    </Grid>
</Page>
